/**
 *   图形生成
 */
 
var Config=function(param,style1,style2){
	//折线图
	var initOption1={
			title : {
				show : true,
				text : '',
				x:'center',
				textStyle: {
					fontWeight: 'border',
					fontSize: 14
					}
			},
		    color:["#22C6C8","#157fcc","#89b4be","#77cfbc","#909f7b","#edba3e","#81b5b6"],
			tooltip: {
		        trigger: 'axis',
				position : 'right',
				formatter: "{b} : {c} "
		    },
		    toolbox: {
		    	show:false,
		    //	itemSize : 18,
			//	itemGap : 18,
		        feature: {
		            dataView: {show: true, readOnly: false},
		            magicType: {show: true, type: ['line', 'bar']},
		            restore: {show: true},
		            saveAsImage: {show: true}
		        }
		    },
		    grid : [ {
				show : true,
				top : 10,
				left : 40,
				right:40,
				bottom:0,
				width : 'auto',
				height : 'auto',
				containLabel : true
			} ],
		    legend: {
		    	width : 'auto',
				height : 'auto',
				itemGap: 10,
				itemWidth: 25,
				itemHeight: 15,
				textStyle: {
					fontSize: 12
					},
		        data:[]
		    },
		    xAxis: [
		        {
		            type: 'category',
		            data: [],
		            axisLine: {
				    	show: true,
				    	onZero: true,
				    	lineStyle: {
				    	color: '#78C1E3'
				    		},
				    	},
		            axisLabel:{
		            	textStyle: {color:'#333'},
		            	formatter: function (param){
		            		if(param.length>=7)
		            			return param.substring(0,4)+'\n'+param.substring(4);
		            		else
		            			return param
		            	}
		            }
		        }
		    ],
		    yAxis: [
		        {
		            type: 'value',
		            axisLine: {
				    	show: true,
				    	onZero: true,
				    	lineStyle: {
				    	color: '#78C1E3'
				    		},
				    	},
				   axisLabel:{
			            	textStyle: {color:'#333'},
			            },
		            name: ''
		        }
		    ],
		    series: []
	};
	var initOption2={
		    title : {
		        text: '',
		        left:'center',
		        textStyle: {
					fontWeight: 'bold',
					fontSize: 16
					}
		    },
		    tooltip : {
		        trigger: 'item',
		        formatter: "{b} : {c} ({d}%)"
		    },
		  // color:["#ED6363","#f69344","#daee2d","#24c652","#5f71d9","#42e0b1",'#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83',  '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
		    legend: {
		    	show:false,
		        orient: 'vertical',
		        left: 'right',
		        top:'center',
		        data: []
		    },
		    series : [
		        {
		            name: '',
		            type: 'pie',
		            radius : '60%',
		            center: ['50%', '50%'],
		            data:[],
		            label: {
		                normal: {
		                    show: true,
		                    formatter:'{value}'
		                },
		                emphasis: {
		                    show: true
		                }
		            },
		            itemStyle: {
		                emphasis: {
		                    shadowBlur: 10,
		                    shadowOffsetX: 0,
		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
		                }
		            },
		            labelLine: {
		            	normal: {
		            	show: false,
		            	length: 7,
		            	length2: 3,
		            	smooth: false
		            	}
		        }}
		    ]
		};
	var initOption3={
			  title: {
			        text: '',
			        left:'center'
			    },
			  tooltip: {}, 
			  legend: {
			        show:true,
			        x : 'center',
			        y : 'bottom',
			        data:[]
			    },
			    radar: [
			        {
			            indicator: [],
			            center: ['50%', '50%'],
			            radius: 90,
			            startAngle: 90,
			            splitNumber: 4,
			            shape: 'circle',
			            name: {
			                formatter:'【{value}】',
			                textStyle: {
			                    color:'#72ACD1'
			                }
			            },
			            splitArea: {
			                areaStyle: {
			                    color: ['rgba(114, 172, 209, 0.2)',
			                    'rgba(114, 172, 209, 0.4)', 'rgba(114, 172, 209, 0.6)',
			                    'rgba(114, 172, 209, 0.8)', 'rgba(114, 172, 209, 1)'],
			                    shadowColor: 'rgba(0, 0, 0, 0.3)',
			                    shadowBlur: 10
			                }
			            },
			            axisLine: {
			                lineStyle: {
			                    color: 'rgba(255, 255, 255, 0.5)'
			                }
			            },
			            splitLine: {
			                lineStyle: {
			                    color: 'rgba(255, 255, 255, 0.5)'
			                }
			            }
			        },
			        {
			            indicator: [],
			            center: ['75%', '50%'],
			            radius: 120
			        }
			    ],
			    series: []
		};
	var initOption4={
		    title : {
		        text: '',
		        left:'center'
		    },
		//    color:["rgb(213,58,53)","#157fcc","#89b4be","#77cfbc","#909f7b","#edba3e","#81b5b6"],
		    tooltip : {
		        trigger: 'item',
		        formatter: "{b} : {c} ({d}%)"
		    },
		    legend: {
		        left: 'center',
		        top:'bottom',
		        data: []
		    },
		    series : [
		        {
		            name: '',
		            type:'pie',
		            radius: ['0%', '75%'],
		            center: ['50%', '50%'],
		            avoidLabelOverlap: true,
		            hoverAnimation:false,
		            label: {
		                normal: {
		                    show: true,
		                    position: 'inside'
		                },
		                emphasis: {
		                    show: true,
		                    textStyle: {
		                        fontSize: '15',
		                        fontWeight: 'bold'
		                    }
		                }
		            },
		            labelLine: {
		                normal: {
		                    show: false
		                }
		            },
		            data:[]
		        }
		    ]
		};
	   var initOption5 = {
			    color:['#d4daF5','#9C6CE5','#BADB70','#5BD6AA','#37C3E4','#587EA5','#D0B2D6','#D5759B','#9C7357','#648260','#525A5C','#EC8576','#FCC06A','#D28856'],
	 		    tooltip: {
	 		        trigger: 'item'
	 		    },
	 		    legend: {
	 		    	show:true,
	 		        orient: 'horizontal',
	 		        top: '71%',
	 		        x: 'center',
	 		        y:'bottom',
	 		        width : 'auto',
					height : 'auto',
					itemGap: 30,
					itemWidth: 25,
					itemHeight: 15,
					textStyle: {
						fontSize: 12
						},
	 		        data:[]
	 		    },
	 		    series: [
	 		        {
	 		            name:'获得学分',
	 		            type:'pie',
	 		            selectedMode: 'single',
	 		            center:['50%','27%'],
	 		            radius: [0, '25%'],
	 		            label: {
	 		                normal: {
	 		                    position: 'center',
	 		                    formatter:function(obj){
	 		                    	return obj.data.name+'\n\n'+obj.data.value;
	 		                    },
	 		                    textStyle: {
	 		                	  color: '#000',
		 		                  fontSize:17
	 		                	  }
	 		                }
	 		            },
	 		            labelLine: {
	 		                normal: {
	 		                    show: false
	 		                }
	 		            },
	 		            data:[]
	 		        },
	 		        {
	 		            name:'类别',
	 		            type:'pie',
	 		           center:['50%','27%'],
	 		            radius: ['35%', '50%'],
	 		            label: {
	 		                normal: {
	 		                	 show: false
	 		                }
	 		            },
	 		            labelLine: {
	 		                normal: {
	 		                    show: false
	 		                }
	 		            },
	 		            data:[]
	 		        }
	 		    ]
	 		};
	return {
		option8:function(jsonObject){
			initOption5.legend.data=jsonObject.legend_data;
			initOption5.series[0].name=jsonObject.style;
			initOption5.series[0].data=jsonObject.series_data_1;
			initOption5.series[1].data=jsonObject.series_data_2;
			return initOption5;
		},
		option1:function(jsonObject){
			initOption1.title.text=param;
			initOption1.title.textStyle.fontWeight='bold';
			initOption1.title.textStyle.fontSize=16;
			initOption1.grid[0].top='25%';
			initOption1.grid[0].bottom=50;
			initOption1.grid[0].left='12%';
			initOption1.grid[0].right='12%';
			initOption1.xAxis[0].data=jsonObject.xAxis_data;
		    initOption1.series.push({
						name:'',
						type:style2,
						symbolSize: 8,
						smooth: style1,
						hoverAnimation : true,
						barMaxWidth:'50%',
						itemStyle : {
							normal : {
							barBorderRadius: [5, 5, 0, 0]
							//color:'#00a0e9'
							},
							 lineStyle: {
		                	     normal: {
		                	//	  color: '#89d7f9'
		                	        }}
						},
						markPoint : {
							symbolSize: 60,
							data : [ {
								name : '最高值',
								type : 'max'
							}, {
								name : '最低值',
								type : 'min'
							} ]
						},
						 label: {
				                normal: {
				                    show: true,
				                    position: 'top',
				                    formatter: '{c}'
				                }
				            },
						data:jsonObject.series_data
			});
			return initOption1;
		},
		option7:function(jsonObject){
			initOption1.title.text=param;
			initOption1.title.textStyle.fontWeight='bold';
			initOption1.title.textStyle.fontSize=16;
			initOption1.xAxis[0].data=jsonObject.xAxis_data;
		    initOption1.series.push({
						name:'',
						type:style2,
						symbolSize: 8,
						smooth: style1,
						hoverAnimation : true,
						barMaxWidth:'50%',
						itemStyle : {
							normal : {
							barBorderRadius: [5, 5, 0, 0]
							},
							 lineStyle: {
		                	     normal: {
		                	        }}
						},
						 label: {
				                normal: {
				                    show: true,
				                    position: 'top',
				                    formatter: '{c}科'
				                }
				            },
						data:jsonObject.series_data
			});
			return initOption1;
		},
		option2:function(jsonObject){
			initOption2.title.text=param;
			initOption2.legend.data=jsonObject.legend_data;
			initOption2.series[0].label.normal.formatter=function(params) {
				if((params.name.length+params.value.toString().length)>8){
					if(16>params.name.length>8)
                      return params.name.substring(0,8)+'\n'+params.name.substring(8)+style1+'：\n'+params.value +style2;
					else if(16<=params.name.length)
					  return params.name.substring(0,8)+'\n'+params.name.substring(8,16)+'\n'+params.name.substring(16)+style1+'：\n'+params.value +style2;	
					else
					  return params.name+style1+'：\n'+params.value +style2;
                  }
				else
			      return params.name+style1+'：'+params.value +style2;
             }
			initOption2.series[0].data=jsonObject.series_data;
			
			return initOption2;
		},
		option3:function(jsonObject){
			initOption3.title.text=param;
			initOption3.legend.data=jsonObject.legend_data;
			initOption3.radar[0].indicator=jsonObject.indicator_data;
			initOption3.series.push({  
				name: '成绩',
	            type: 'radar',
	            data: [
	                {
	                	 value: jsonObject.series_data[0],
		                 name: jsonObject.legend_data[0],
	                    label: {
	                        normal: {
	                            show: true,
	                            formatter:function(params) {
	                                return params.value;
	                            }
	                        }
	                    }
	                },
	                {
	                	 value: jsonObject.series_data[1],
		                  name: jsonObject.legend_data[1],
	                }
	            ]
	      });
			return initOption3;
		},
		option4:function(jsonObject){
			initOption4.title.text=param;
			initOption4.legend.data=jsonObject.legend_data;
			initOption4.series[0].data=jsonObject.series_data
			return initOption4;
		},
		option5:function(jsonObject){
			initOption1.title.text=param;
			initOption1.title.textStyle.fontWeight='bold';
			initOption1.title.textStyle.fontSize=14;
			initOption1.xAxis[0].data=jsonObject.xAxis_data;
			for(var i=0;i<jsonObject.legend_data.length;i++){
		    initOption1.series.push({
						name:jsonObject.legend_data[i],
						type:style2,
						smooth: style1,
						itemStyle : {
							normal : {
							barBorderRadius: [5, 5, 0, 0]
							//color:'#00a0e9'
							},
							 lineStyle: {
		                	     normal: {
		                	//	  color: '#89d7f9'
		                	        }}
						},
						label: {
			                normal: {
			                    show: true,
			                    position: 'top',
			                    formatter: '{c}'
			                }
			            },
						hoverAnimation : true,
						data:jsonObject.series_data[i]
			});}
			return initOption1;
		},
		option6:function(jsonObject){
			initOption1.title.text=param;
			initOption1.title.x='left';
			initOption1.title.textStyle.fontWeight='bold';
			initOption1.title.textStyle.fontSize=14;
			initOption1.grid[0].top='25%';
			initOption1.toolbox.show='true';
			initOption1.xAxis[0].data=jsonObject.xAxis_data;
			
			initOption1.legend.data=jsonObject.legend_data;
			for(var i=0;i<jsonObject.legend_data.length;i++){
		    initOption1.series.push({
						name:jsonObject.legend_data[i],
						type:style2,
						smooth: style1,
						hoverAnimation : true,
						markPoint : {
							symbolSize: 60,
							data : [ {
								name : '最高值',
								type : 'max'
							}, {
								name : '最低值',
								type : 'min'
							} ]
						},
						data:jsonObject.series_data[i]
			});}
			return initOption1;
		}
	};
};